Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-voronoi

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-voronoi

Compute the Voronoi diagram of a set of two-dimensional points.

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
increased by15.77%
Maintainers
1
Weekly downloads
 
Created

What is d3-voronoi?

The d3-voronoi npm package is a part of the D3.js library and is used to compute Voronoi diagrams. Voronoi diagrams partition a plane into regions based on the distance to a specific set of points. This package is useful for spatial analysis, data visualization, and creating interactive graphics.

What are d3-voronoi's main functionalities?

Compute Voronoi Diagram

This feature allows you to compute a Voronoi diagram for a given set of points. The code sample demonstrates how to create a Voronoi diagram for three points within a specified extent.

const d3 = require('d3-voronoi');
const points = [[200, 200], [400, 400], [600, 600]];
const voronoi = d3.voronoi().extent([[0, 0], [800, 800]]);
const diagram = voronoi(points);
console.log(diagram.cells);

Find Voronoi Cell for a Point

This feature allows you to find the Voronoi cell that contains a specific point. The code sample demonstrates how to find the cell for the point (300, 300).

const d3 = require('d3-voronoi');
const points = [[200, 200], [400, 400], [600, 600]];
const voronoi = d3.voronoi().extent([[0, 0], [800, 800]]);
const diagram = voronoi(points);
const cell = diagram.find(300, 300);
console.log(cell);

Render Voronoi Diagram with SVG

This feature allows you to render a Voronoi diagram using SVG. The code sample demonstrates how to create an SVG representation of the Voronoi diagram for three points.

const d3 = require('d3-voronoi');
const points = [[200, 200], [400, 400], [600, 600]];
const voronoi = d3.voronoi().extent([[0, 0], [800, 800]]);
const diagram = voronoi(points);
const svg = `<svg width="800" height="800">
  ${diagram.cells.map(cell => `<path d="M${cell.halfedges.map(i => diagram.edges[i].join('L')).join('L')}Z" stroke="black" fill="none" />`).join('')}
</svg>`;
console.log(svg);

Other packages similar to d3-voronoi

Keywords

FAQs

Package last updated on 24 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc